#include <iostream>
#include <vector>//容器
#include <algorithm>//算法
//　for_each是C++ 11标准的STL库中新增加的函数模板，声明于<algorithm>头文件。

using namespace std;

template<class T>
class myvectorprint
{
public:
    void operator ()(const T &t)
    {
        
        std::cout<<t <<std::endl;
    }
    
};

int main()
{
    
    vector<int> myvector;
    myvector.push_back(11);
    myvector.push_back(21);
    myvector.push_back(31);
    myvector.push_back(81);
    myvector.push_back(51);
    myvectorprint<int >print;
    for_each (myvector.begin(), myvector.end(),print);
    cin.get();
    return 0;
}